<template>
    <el-dialog  :visible.sync="showDialog"  width="30%" :before-close="handleClose">
        <el-form label-width="80px">
             <el-form-item label="名称">
                <el-input></el-input>
            </el-form-item>
            <el-form-item label="封面图">
                <el-upload action="" class="upload-demo" :before-upload="handleBeforeUpload">
                     <el-button size="small" type="primary">点击上传</el-button>
                     <div slot="tip" class="el-upload__tip">只能上传jpg/png文件，且不超过500kb</div>
                </el-upload>
            </el-form-item>
             <el-form-item>
            <el-button type="primary" @click="submit">立即创建</el-button>
            <el-button>取消</el-button>
         </el-form-item>
        </el-form>
    </el-dialog>
</template>
<script>
export default {
   props:['showDialog'],
   data(){
       return {
           id:'',
           name:'',
           img:''
       }
   },
   computed:{
       show:{
           get:function(){
               return this.showDialog;
           }
       }
   },
   methods:{
      handleClose(done){
           this.$confirm('确认关闭？')
          .then(_ => {
            //this.showDialog = false;
            this.name = "";
            this.img = "";
            this.$emit('showTest')
          })
          .catch(_ => {});
      },
      submit(){
         let data = new FormData();
         data.append('name',this.name);
         data.append('img',this.file);
         this.$store.dispatch('updateStrategy',data);
      },
      handleBeforeUpload(file){
        this.img = file;
        return false;
      }
   }
}
</script>
<style scoped>
    
</style>
